#pragma once

// Alignment.
#define GCC_PACK(n)
#define GCC_ALIGN(n)
#define GCC_BITFIELD_MAGIC
#define MS_ALIGN(n) __declspec(align(n))
#define ALIGN_NEW(Type, Param) (new(_aligned_malloc(sizeof(Type), 16))Type Param)
#define ALIGN_DELETE(Type, P) {(P)->~Type(); _aligned_free(P);}

#define loop(v,m)	for(int v = 0; v<int(m); v++)
#define loopi(m)	loop(i,m)
#define loopj(m)	loop(j,m)
#define loopk(m)	loop(k,m)
#define loopl(m)	loop(l,m)
#define loopv(v)    for(size_t i = 0; i<(v).size(); i++)
#define loopvj(v)   for(size_t j = 0; j<(v).size(); j++)
#define loopvk(v)   for(size_t k = 0; k<(v).size(); k++)
#define loopvrev(v) for(size_t i = (v).size()-1; i>=0; i--)

#ifdef _DEBUG
#define VERIFY_D3D(EXP) assert(EXP == 0)
#else
#define VERIFY_D3D(EXP) (EXP)
#endif

#define SAFE_RELEASE(p)			{ if(p) { p->Release(); p = NULL; }	}
#define SAFE_DELETE(p)			{ if(p) { delete p; p = NULL; }		}
#define SAFE_DELETE_ARRAY(p)	{ if(p) { delete[] p; p = NULL; }	}
#ifndef NULL
#define NULL 0
#endif

#ifndef DWORD
typedef unsigned long       DWORD;
typedef int                 INT;
typedef unsigned int		UINT;
typedef int                 BOOL;
typedef unsigned char       BYTE;
typedef unsigned short      WORD;
typedef short				SHORT;
typedef float               FLOAT;
typedef _w64 unsigned int	WPARAM;
typedef _w64 long			LPARAM;
typedef void*				HANDLE;
#endif

// Constants.
#undef  PI
#define PI 					(3.1415926535897932f)
#define INV_PI				(0.31830988618f)
#define HALF_PI				(1.57079632679f)
#define SMALL_NUMBER		(1.e-8f)
#define KINDA_SMALL_NUMBER	(1.e-4f)
#define BIG_NUMBER			(3.4e+38f)
#define EULERS_NUMBER       (2.71828182845904523536f)
#define MAX_INFLUENCES		(4)
#define DEFAULT_GRAVITY		(-980.0f)

// Aux constants.
#define MAX_WORLD_SIZE		(50000)
#define MAX_MRT_NUM			(8)
#define TITLE				L"Shooter"
#define SHADER_PATH			"../Shader/"
#define CONTENT_PATH		"../Content/"
#define DEFAULT_WIDTH		(1024)
#define DEFAULT_HEIGHT		(600)
#define DEFAULT_PORT		(2012)
#define PLATFORM_URL		L"www.frozenpeak.cn"
#define PLATFORM_PORT		(2012)

// physics.
#define SIMPLE_PHYSICS		(1)

#include <string>
#include <assert.h>
#include "Template.h"
#include "MathSSE.h"
#include "MathHelper.h"
#include "Math.h"
#include "Vector2.h"
#include "Vector3.h"
#include "Vector4.h"
#include "Plane.h"
#include "PackedVector.h"
#include "Quaternion.h"
#include "Rotator.h"
#include "Matrix.h"
#include "AxisAlignedBox.h"
#include "BoxCenterAndExtent.h"

class SceneManager;
class Render;
class RenderWindow;
class Camera;
class MultiRenderTarget;
class Shader;
class Shape;
class Scene;
class SceneNode;
class MovableObject;
class Entity;
class RenderQueue;
class Renderable;
class RenderView;
class Material;
class MaterialInstance;
